﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace HHHFramework {
    public class ResKitUtil
    {
        /// <summary>
        /// 获取一个resources资源路径  
        /// </summary>
        /// <param name="resPath"></param>
        /// <returns></returns>
        public static string GetResourcesPath(string resPath) {
            if(!resPath.Contains("resources://")) { return "resources://" + resPath; }
            return resPath;
        }

        /// <summary>
        /// streamAssetPath 
        /// </summary>
        /// <param name="assetBundleName"></param>
        /// <returns></returns>
        public static string FullPathForAssetBundle(string assetBundleName) {
            return Application.streamingAssetsPath + "/AssetBundles/"+ GetPlatformName() + "/" + assetBundleName;
        }

        /// <summary>
        /// persistentDataPath
        /// </summary>
        public static string PersistentAssetBundleFolder{
            get {

                return Application.persistentDataPath+"/AssetBundles/";
            }

        }


        public static string GetPlatformName(){

            return "StandaloneWindows";
            //#if UNITY_EDITOR
            //                return GetPlatformName(UnityEditor.EditorUserBuildSettings.activeBuildTarget);

            //#else
            //                return GetPlatformName(Application.platform);
            //#endif

        }
#if UNITY_EDITOR
        private static string GetPlatformName(UnityEditor.BuildTarget buildTarget)
        {

            switch (buildTarget)
            {
                case UnityEditor.BuildTarget.StandaloneWindows: return "StandaloneWindows";
                case UnityEditor.BuildTarget.StandaloneWindows64:
                    return "StandaloneWindows";
                case UnityEditor.BuildTarget.iOS:
                    return "iOS";
                case UnityEditor.BuildTarget.Android:
                    return "Linux";
                case UnityEditor.BuildTarget.StandaloneOSX:
                    return "OSX";
                case UnityEditor.BuildTarget.WebGL:
                    return "WebGL";
                default: return null;
            }
        }
#else

        private static string GetPlatformName( RuntimePlatform runtimePlatform) {
            switch (runtimePlatform)
            {
                case RuntimePlatform.WebGLPlayer:
                    return "WebGL";
                case RuntimePlatform.OSXPlayer:
                    return "OSX";
                case RuntimePlatform.WindowsPlayer:
                    return "Windows";
                case RuntimePlatform.IPhonePlayer:
                    return "iOS";
                case RuntimePlatform.Android:
                    return "Android";

                default: return null;
            }
        }
    
#endif
    }
}

